% Load the baseline parameters that are common across programs
clear;
global g rho sigma PStar taub tauh k l tau tauBarBench zBarBench zTildeBench
global z0_1 z0_2; % Load test shocks for the baseline case
% global QArr QArrN rpActualArr rpRequiredArr_1 rpRequiredArr_2 rpRequiredArr_3;

% Load general parameters
g = 0.05;
rho=0.05;
PStar = exp(-rho)/(1-exp(-rho));

sigma = 0.24; 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load the parameters and shocks and calculate the equilibrium
% for the baseline case with unique equilibrium
taub = 3;
tauh =1/3;
assert(tauh < sigma^2/(rho+g));
ph = exp(rho+g - sigma^2/tauh);
l =0.8;

% Solve banks' share k where the baseline Sharpe ratio is 0.4
sharpeTarget=0.4;
k = fsolve(@(kTilde) sigma/(taub*kTilde*(1-l)+tauh*(1-kTilde*(1-l)))-0.4,0.5);
tau = taub*k+tauh*(1-k);
tauBarBench = taub*k*(1-l)+tauh*(1-k*(1-l));
assert( tauBarBench>= sigma^2/(rho+g));
zBarBench = fsolve(@(z) tau - k*l/z*(taub-tauh) -  sigma^2/(rho+g),1);

% Find the other threshold: the threshold above which banks avoid
% bankruptcy (z^h in the paper)
zTildeBench = l/ph;

% Check that this is below zBar
% Otherwise, the well behaved region does not exist
assert(zTildeBench<zBarBench);
z0_1 = 1;
z0_2 = zTildeBench+0.05*(zBarBench-zTildeBench);
